exports.forge_once = function(player, req, resp, onHandled) {
    do{ 
        var user = player.user;
        if( user.status.level < gConfGlobal.ForgeOpenLevel ) { 
            resp.code = 1; resp.desc = 'level limit'; break;
        }   

        var forge = user.forge;
        if( forge.total >= gConfGlobal.ForgeTotalTime ) {
            resp.code = 1; resp.desc = 'forge finished'; break;
        }

        if( forge.today >= gConfGlobal.ForgeDailyLimit ) {
            resp.code = 1; resp.desc = 'daily limit'; break;
        }

        var goldGain = gConfGlobal.ForgeGold;
        player.costResource('gold', -goldGain);

        forge.today ++; 
        forge.total ++; 
        player.markDirty('forge');

        resp.data.gold = goldGain;

    }while(false);

    onHandled();
}

exports.get_award = function(player, req, resp, onHandled) {
    do{ 
        var user = player.user;
        if( user.status.level < gConfGlobal.ForgeOpenLevel ) { 
            resp.code = 1; resp.desc = 'level limit'; break;
        }   

        var forge = user.forge;
        if( forge.got == 1 ) {
            resp.code = 1; resp.desc = 'have got'; break;
        }

        if( forge.total < gConfGlobal.ForgeTotalTime ) {
            resp.code = 1; resp.desc = 'forge not finish'; break;
        }

        forge.got = 1;
        player.markDirty('forge.got');

        resp.data.awards = player.addAwards([['equip', 'weapon', '13', 1]]);

    }while(false);

    onHandled();
}
